<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateBansTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('bans', function (Blueprint $table) {
            $table->id()->from(config('migration.from'));

            $table->bigInteger('user_id')->unsigned()->nullable();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');

            $table->bigInteger('profile_id')->unsigned()->nullable();
            $table->foreign('profile_id')->references('id')->on('profiles')->onDelete('cascade')->onUpdate('cascade');

            $table->bigInteger('banned_by_id')->unsigned()->nullable();
            $table->foreign('banned_by_id')->references('id')->on('profiles')->onDelete('set null')->onUpdate('cascade');

            $table->text('ban_comment')->nullable();
            $table->text('unban_comment')->nullable();

            $table->timestamp('banned_at')->nullable();
            $table->timestamp('unbanned_at')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('bans');
    }
}
